package com.dk.controller;

import com.dk.mapper.BooksMapper;
import com.dk.pojo.Books;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.sql.DataSource;
import java.util.List;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/4 22:58
 * @Version 1.0
 **/
@Controller
public class BooksController {

    @Autowired
    private DataSource dataSource;

    @Autowired
    private BooksMapper booksMapper;

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("findAll")
    @ResponseBody
    public List<Books> findAll(){
        //System.out.println(dataSource);
        List<Books> books = booksMapper.selectByExample(null);
        redisTemplate.boundHashOps("bookd").put("b",books);
        rocketMQTemplate.convertAndSend("myTopic","hello mq");
        return books;
    }
}

